//二叉树的最大深度
#include <stdio.h>
#include "tree_node.h"

static int maxVal(int x, int y)
{
    return x > y ? x : y;
}

static int maxDepth(struct TreeNode *root)
{
    if (root == NULL)
    {
        return 0;
    }
    return 1 + maxVal(maxDepth(root->left), maxDepth(root->right));
}
int main_13()
{
    struct TreeNode node1 = {3,  NULL, NULL};
    struct TreeNode node2 = {9,  NULL, NULL};
    struct TreeNode node3 = {20, NULL, NULL};
    struct TreeNode node4 = {15, NULL, NULL};
    struct TreeNode node5 = {7,  NULL, NULL};

    node1.left  = &node2;
    node1.right = &node3;
    node3.left  = &node4;
    node3.right = &node5;

    int deep = maxDepth(&node1);
    printf("%d\n", deep);
}